import {View, Button, Text, Image, ScrollView, Radio} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React from 'react';
import {connect} from 'react-redux';
import * as T from '../../types';
import './index.less';
import actions from '../../actions';
import {store2Props} from '../../selectors';
import testImg from '@/assets/image/ipland/test.png';
import receive from '@/assets/image/ipland/receive.png';
import {IMAGE_EMPTY} from '../../constant';

//@ts-ignore
actions().actions.loadReducer();
//@ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class toBeCollected extends React.Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    let {
      i,
      item,
      main: {allcheck, list},
      actions: {action},
    } = this.props;

    if (!item) return null;
    return (
      <View className="toBeDeliveredItemBox">
        {!item.whetherOrder && <Radio className="toBeDeliveredRadio" checked={item.checked} />}

        <View
          className="toBeDeliveredItem"
          onClick={() => {
            if (!item.whetherOrder) {
              action.commonChange(
                `main.list`,
                JSON.parse(JSON.stringify(list)).map((e) => ({
                  ...e,
                  checked: item.id === e.id ? !item.checked : e.checked,
                })),
              );
            }
          }}
        >
          <View className="toBeDeliveredItem-left">
            <Image className="toBeDeliveredItem-img" src={item.goodsInfoImg || IMAGE_EMPTY} mode="aspectFit" />
            <View className="toBeDeliveredItem-info">
              <Text className="toBeDeliveredItem-info-name">{item.goodsInfoName}</Text>
              <Text className="toBeDeliveredItem-info-price1">市场价：￥{item.price || '0'}</Text>
              <Text className="toBeDeliveredItem-info-price2">实付￥0</Text>
            </View>
          </View>
          <View className="toBeDeliveredItem-controll">
            {/* <Text className="setOrder" onClick={()=>{
            this.props.actions.action.placeOrder(item)
          }}>下单</Text> */}
            {/* <Image className="toBeDeliveredItem-controll-btn" src={receive} mode="widthFix" /> */}
            <Text className="toBeDeliveredItem-controll-tip">
              {item.whetherOrder ? '已下单' : `还有${item.endDay}天到期`}{' '}
            </Text>
          </View>
        </View>
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
